var API_HOST = ""

$.ajaxSetup({
  xhrFields: { withCredentials: true }
})

$.getJSON = (url, data, cb) => {
  return $.ajax({
    type: 'GET',
    url: API_HOST + url,
    data: data,
    xhrFields: { withCredentials: true },
    success: cb
  })
}

$.putJSON = (url, data, cb) => {
  return $.ajax({
    type: 'PUT',
    url: API_HOST + url,
    contentType: 'application/json',
    data: JSON.stringify(data),
    dataType: 'json',
    xhrFields: { withCredentials: true },
    success: cb
  })
}

$.patchJSON = (url, data, cb) => {
  return $.ajax({
    type: 'PATCH',
    url: API_HOST + url,
    contentType: 'application/json',
    data: JSON.stringify(data),
    dataType: 'json',
    xhrFields: { withCredentials: true },
    success: cb
  })
}

$.postJSON = (url, data, cb) => {
  return $.ajax({
    type: 'POST',
    url: API_HOST + url,
    contentType: 'application/json',
    data: JSON.stringify(data),
    dataType: 'json',
    xhrFields: { withCredentials: true },
    success: cb
  })
}

$.deleteJSON = (url, data, cb) => {
  return $.ajax({
    type: 'DELETE',
    url: API_HOST + url,
    contentType: 'application/json',
    data: JSON.stringify(data),
    dataType: 'json',
    xhrFields: { withCredentials: true },
    success: cb
  })
}
